package com.xiaode.controller.app.notify;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Ret;
import com.xiaode.util.apidoc.annotation.Api;
import com.xiaode.util.apidoc.annotation.ApiOper;
import com.xiaode.util.apidoc.annotation.ApiPara;

/**
 * 通知服务
 */
@Path("/notify")
@Api("通知服务")
@EnableCORS
public class NotifyController extends Controller {
	
	 @Inject
	 private NotifyService service;
	 
	 /**
	  * 通知未读数量
	  */
	 @ApiOper("我的通知未读数量")
	 public void noReadNotifyTotalNumber() throws Exception{
		 Integer accountId = getAttr("accountId");
		 Ret ret = service.noReadNotifyTotalNumber(accountId);
		 renderJson(ret);
	 }
	 
	 /**
	  * 我的通知列表
	  * 需要多个表合并查询
	  */
	 @ApiOper("我的通知列表")
	 public void getNotifyList(
			 @NotEmpty @Size(min = 0) @ApiPara(value = "page", notes = "当前页") Integer page, 
			 @NotEmpty @Size(min = 0) @ApiPara(value = "limit", notes = "每页大小") Integer limit) throws Exception{
		 Integer accountId = getAttr("accountId");
		 Integer userType = getAttr("userType");
		 Ret ret = service.getNotifyList(accountId, userType, page, limit);
		 renderJson(ret);
	 }
	 
	 /**
	  * 阅读操作
	  */
	 @ApiOper("我的通知列表")
	 public void setRead(@NotEmpty @ApiPara(value = "notifyLogId", notes = "通知id") Integer notifyLogId) throws Exception{
		 Integer accountId = getAttr("accountId");
		 Ret ret = service.setRead(accountId, notifyLogId);
		 renderJson(ret);
	 }
	 
	 
	 
	 
	 
	 
	 
}
